package com.lyt.springboot.util.algorithm;

public class S6 {
    //冒泡排序
    //相邻两个数字比较  遍历----》直到从大到小  当然了也可以从小到大
    public int[] maopao(int[] arr) {
        for (int i = 0; i <arr.length ; i++) {
            for(int j = 0;j<arr.length-1;j++) {
                if(arr[j]<arr[j+1]) {
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }

            }
        }
        return arr;
    }

    public static void main(String[] args) {
        int[] arr = {2,4,5,1,8,9,100,99,80,7};
        S6  s6 = new S6();
        int[] maopao = s6.maopao(arr);
        for (int i = 0; i < maopao.length; i++) {
            System.out.println(maopao[i]);
        }

    }

}
